package com.jlb.jobhandler;


import com.jlb.base.HttpTool;
import com.jlb.base.UrlEnum;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * 删除么有复投的矿机
 * 每天晚上
 * 0 30 0 * * ?
 */
@JobHandler(value = "overdueMinerJobHandler")
@Component
public class OverdueMinerJobHandler extends IJobHandler {

    @Autowired
    private HttpTool httpTool;

    /**
     * 将工厂端产生的数据上传到云端进行备份保存
     *
     * @param param 执行默认传值
     * @return ReturnT<String>
     * @throws Exception
     */
    @Override
    public ReturnT<String> execute(String param) throws Exception {
        XxlJobLogger.log("-------------------Begin >> 删除么有复投的矿机------------------ ");
        String result = null;
        String jobToken = httpTool.get(UrlEnum.JobTokenUrl);
        if (jobToken != null) {
            result = httpTool.get(UrlEnum.DeleteMinerUrl, jobToken);
        }
        XxlJobLogger.log("-------------------End >> 删除么有复投的矿机------------------ " + result);
        return SUCCESS;
    }


}
